import React from 'react'
import {Provider} from 'react-redux'
import App from 'next/app'
import Head from 'next/head'
import WithReduxApp from '../store/with-redux'
import 'antd-mobile/dist/antd-mobile.min.css'
import "@/scss/reset.scss"
import '@/scss/app.scss'
class MyApp extends App {
  static async getInitialProps({ Component, ctx }) {
    let pageProps = {}
    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx)
    }

    return { pageProps }
  }
  // static async getInitialProps({ Component, ctx }) {
  //   let pageProps = {}
  //   if (Component.getInitialProps) {
  //     pageProps = await Component.getInitialProps(ctx)
  //   }
  //   console.log(`app`);
  //   console.log(pageProps);
  //   return { pageProps }
  // }

  render () {
    // @ts-ignore
    const {Component, pageProps, store} = this.props;
    const {title, description, keywords, author } = store.getState();
    return (
      <>
      <Head>
          <meta name ="viewport" content ="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, viewport-fit=cover"  />
          
          
          <link rel="icon" type="image/icon" href="//f3-md.veimg.cn/meadinindexnew/v1.0.3/static/app/1.0.0/meadin/images/bitbug_favicon.ico" />
          <meta content={description} name="description" /> 
          <meta content={keywords} name="keywords" />
          <meta name="author" content={author}/>
          <link rel="canonical" href="https://i.meadin.com/" />
          <title>{title}</title>
           {/* <script src="https://f3-md.veimg.cn/meadin/mobile/lib/vconsole.min.js"></script>
           <script>
            var vConsole = new VConsole();
            console.log('VConsole is cool');
          </script> */}
        </Head>
        <Provider store={store}>
          <Component {...pageProps} />
        </Provider>
      </>
    )
  }
}
export default WithReduxApp(MyApp)

// export default withRedux(initializeStore)(class MyApp extends App {
//   static async getInitialProps ({Component, ctx}) {
//     return {
//       pageProps: (Component.getInitialProps ? await Component.getInitialProps(ctx) : {})
//     }
//   }
//   // 微信网页分享
//   // componentDidMount() {
//   //   console.log(1222)
//   //   wxShareContent()
//   // }
//   // UNSAFE_componentWillReceiveProps() {
//   //    console.log('componentWillReceiveProps')
//   //   wxShareContent()
//   // }
//   render () {
//     const {Component, pageProps, store} = this.props
//     const {title, description, keywords, author } = store.getState();
//     return (
//       <>
//         <Head>
//           <meta name ="viewport" content ="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
//           <meta  content="ie=edge" />
//           <script type="text/javascript" src="/static/asserts/antd-hd.js"></script>
          
//           <link rel="icon" type="image/icon" href="//f3-md.veimg.cn/meadinindexnew/v1.0.3/static/app/1.0.0/meadin/images/bitbug_favicon.ico" />
//           <meta content={description} name="description" /> 
//           <meta content={keywords} name="keywords" />
//           <meta name="author" content={author}/>
//           <link rel="canonical" href="https://i.meadin.com/" />
//           <title>{title}</title>
//            {/* <script src="https://f3-md.veimg.cn/meadin/mobile/lib/vconsole.min.js"></script>
//            <script>
//             var vConsole = new VConsole();
//             console.log('VConsole is cool');
//           </script> */}
//         </Head>
//         <Provider store={store}>
//           <Component {...pageProps} />
//         </Provider>
//       </>
//     )
//   }
// })